/**
 * Copyright (C) 2013 DaiKit.com - daikit4gxt-sample module (admin@daikit.com)
 *
 *         Project home : http://code.daikit.com/commons
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *         http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.daikit.daikit4gxtsample.client.screen.testscreen;

import com.daikit.daikit4gxt.client.action.DkBaseAction;
import com.daikit.daikit4gxt.client.screen.DkBaseScreen;
import com.daikit.daikit4gxtsample.client.screen.testscreen.producteditor.ProductEditorController;
import com.daikit.daikit4gxtsample.client.screen.testscreen.producteditor.ProductEditorUI;
import com.daikit.daikit4gxtsample.shared.bean.ProductData;
import com.sencha.gxt.core.client.util.Margins;
import com.sencha.gxt.widget.core.client.container.BorderLayoutContainer;
import com.sencha.gxt.widget.core.client.container.BorderLayoutContainer.BorderLayoutData;


/**
 * Test Screen
 * 
 * @author tcaselli
 * @version $Revision$ Last modifier: $Author$ Last commit: $Date$
 */
public class TestScreen extends DkBaseScreen
{

	private final TestScreenController testScreenController;
	private final ProductEditorController productEditorController;
	private final TestScreenSearchUI testScreenSearchUI;
	private final ProductEditorUI productEditorUI;

	/**
	 * Constructor
	 */
	public TestScreen()
	{
		setHeaderVisible(false);

		testScreenController = new TestScreenController(this);

		// *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
		// TEST SCREEN UI
		// *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-

		testScreenSearchUI = new TestScreenSearchUI(testScreenController);

		// *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
		// EDITOR
		// *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-

		productEditorUI = new ProductEditorUI()
		{

			@Override
			protected void onProductChanged(final ProductData productData)
			{
				testScreenController.onProductChanged(productData);
			}
		};
		productEditorController = productEditorUI.getController();

		// *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
		// SCREEN LAYOUT
		// *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-

		final BorderLayoutContainer borderLayout = new BorderLayoutContainer();

		final BorderLayoutData northBorderLayoutData = new BorderLayoutData();
		northBorderLayoutData.setCollapsible(true);
		northBorderLayoutData.setSplit(true);
		northBorderLayoutData.setMinSize(100);
		northBorderLayoutData.setSize(250);
		northBorderLayoutData.setMargins(new Margins(2, 2, 1, 2));
		borderLayout.setNorthWidget(testScreenSearchUI, northBorderLayoutData);

		final BorderLayoutData centerBorderLayoutData = new BorderLayoutData();
		centerBorderLayoutData.setMargins(new Margins(0, 2, 1, 2));
		borderLayout.setCenterWidget(productEditorUI, centerBorderLayoutData);
		add(borderLayout);
	}

	@Override
	public void invalidateUi()
	{
		// Nothing done
	}

	@Override
	public DkBaseAction<?> getReloadScreenAction(final boolean force, final Object... optionalArgs)
	{
		return null;
	}

	/**
	 * @return the testScreenSearchUI
	 */
	public TestScreenSearchUI getTestScreenSearchUI()
	{
		return testScreenSearchUI;
	}

	/**
	 * @return the productEditorUI
	 */
	public ProductEditorUI getProductEditorUI()
	{
		return productEditorUI;
	}

	/**
	 * @return the testScreenController
	 */
	public TestScreenController getTestScreenController()
	{
		return testScreenController;
	}

	/**
	 * @return the productEditorController
	 */
	public ProductEditorController getProductEditorController()
	{
		return productEditorController;
	}
}
